package com.ruoyi.web.controller.production;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.production.domain.vo.CheckOutVo;
import com.ruoyi.production.domain.vo.ProductionExitVo;
import com.ruoyi.production.service.ProductionExitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: YwaiX
 * @Version: 1.0
 * @Date: Created in 2024-11-04 10:34:52
 * @Description: 生产退料
 */

@RestController
@RequestMapping("/production/exit")
public class ProductionExitController extends BaseController {

    @Autowired
    private ProductionExitService productionExitService;

    /**
     * 获取退料记录
     * @return
     */
    @GetMapping("list")
    public TableDataInfo list(){
        startPage();
        List<ProductionExitVo> list = productionExitService.list();
        return getDataTable(list);
    }

    /**
     * 获取领料数量列表
     * @param productionNo
     * @return
     */
    @GetMapping("checkout")
    public TableDataInfo checkout(String productionNo){
        startPage();
        List<CheckOutVo> list = productionExitService.checkout(productionNo);
        return getDataTable(list);
    }

    /**
     * 退料
     * @param checkOutVo
     * @return
     */
    @PostMapping("return")
    public AjaxResult returnMaterial(@RequestBody CheckOutVo checkOutVo){
        return toAjax(productionExitService.returnMaterial(checkOutVo));
    }
}
